﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace HFK.DxFluentUI.Utility
{
  public class ExpressionHelper
  {
    public static int ExpressionDepth<T, U>(Expression<Func<T, U>> expression)
    {
      int depth = 0;
      MemberExpression memberExpression = expression.Body as MemberExpression;
      while (memberExpression != null)
      {
        depth++;
        memberExpression = memberExpression.Expression as MemberExpression;
      }

      return depth;
    }

    public static Type ExpressionType<T, U>(Expression<Func<T, U>> expression)
    {
      return typeof(U);
    }

  }
}
